/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * POS_CheckoutCard.java
 *
 * Created on Apr 4, 2011, 6:43:27 PM
 */

package POS_Source;

import POS_Controller.POSController;

/**
 * this class renders card payment simulated view
 * @author edaype
 * @see POS_Source
 */
public class POS_CheckoutCard extends javax.swing.JPanel {

    private POSController controller;
    private double amount;
    /** Creates new form POS_CheckoutCard */
    public POS_CheckoutCard(POSController control, double amount) {
        initComponents();
        controller = control;
        this.amount = amount;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TitlePanel = new javax.swing.JPanel();
        TitleLabel = new javax.swing.JLabel();
        MainPanel = new javax.swing.JPanel();
        InstructionsLabel = new javax.swing.JLabel();
        SimulateButton = new javax.swing.JButton();
        WaitingLabel = new javax.swing.JLabel();
        InstructionsLabel1 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        TitlePanel.setBackground(new java.awt.Color(255, 255, 255));

        TitleLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 60)); // NOI18N
        TitleLabel.setText("Card Payment");

        javax.swing.GroupLayout TitlePanelLayout = new javax.swing.GroupLayout(TitlePanel);
        TitlePanel.setLayout(TitlePanelLayout);
        TitlePanelLayout.setHorizontalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TitleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 504, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(461, Short.MAX_VALUE))
        );
        TitlePanelLayout.setVerticalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TitlePanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(TitleLabel)
                .addContainerGap())
        );

        MainPanel.setBackground(new java.awt.Color(255, 255, 255));
        MainPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        InstructionsLabel.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        InstructionsLabel.setText("Please swipe your card at the Terminal.");

        SimulateButton.setBackground(new java.awt.Color(255, 255, 255));
        SimulateButton.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        SimulateButton.setText("Simulate Response");
        SimulateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SimulateButtonActionPerformed(evt);
            }
        });

        WaitingLabel.setFont(new java.awt.Font("Tahoma", 2, 24)); // NOI18N
        WaitingLabel.setText("Waiting For Response...");

        javax.swing.GroupLayout MainPanelLayout = new javax.swing.GroupLayout(MainPanel);
        MainPanel.setLayout(MainPanelLayout);
        MainPanelLayout.setHorizontalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(164, 164, 164)
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(SimulateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(WaitingLabel)
                    .addComponent(InstructionsLabel))
                .addContainerGap(181, Short.MAX_VALUE))
        );
        MainPanelLayout.setVerticalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addComponent(InstructionsLabel)
                .addGap(82, 82, 82)
                .addComponent(WaitingLabel)
                .addGap(63, 63, 63)
                .addComponent(SimulateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(120, Short.MAX_VALUE))
        );

        InstructionsLabel1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        InstructionsLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/POS_Source/images/Logo.png"))); // NOI18N
        InstructionsLabel1.setText(" ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(MainPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(TitlePanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(InstructionsLabel1, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(InstructionsLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TitlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    /**
     * this method handles button press event and directs the request to controller
     * @param evt
     */
    private void SimulateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SimulateButtonActionPerformed
        controller.makePayment(amount);
    }//GEN-LAST:event_SimulateButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel InstructionsLabel;
    private javax.swing.JLabel InstructionsLabel1;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JButton SimulateButton;
    private javax.swing.JLabel TitleLabel;
    private javax.swing.JPanel TitlePanel;
    private javax.swing.JLabel WaitingLabel;
    // End of variables declaration//GEN-END:variables

}
